gcapp.set "messageVisible","false"

! line 1 is the tag, 2 is contents to delete
Lines "#sm",1,0,@gcapp.scriptMessage
#theTag=#sm[1]
#contents=#sm[2]
#inUndo=#sm[3]

! get tags (exit if none)
gcapp.get doc,frontDocument
doc.get recRef,"keyRecord"
recRef.findStructures currentTags,#theTag,#contents
if @currentTags.count=0
  beep
  exit
endif

! Delete it
doc.beginUndo
currentTags.0.delete
doc.endUndo #inUndo
